﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using CafeOnline.MvcFramework.Grid;

namespace CafeOnline.MvcFramework.Interfaces {
    public interface IGrid : IHtmlString {
        #region Properties

        /// <summary>
        /// Gets the options of the grid
        /// </summary>
        GridOptions Options {
            get;
        }

        /// <summary>
        /// Gets the custom settings of this grid.
        /// </summary>
        GridCustomSettings CustomSettings { get; }

        /// <summary>
        /// Gets the ID of the grid.
        /// </summary>
        string ID {
            get;
        }

        /// <summary>
        /// Gets the type of the grid.
        /// </summary>
        string Type { get; }


        /// <summary>
        /// Enumerates the columns that are visible.
        /// </summary>
        IEnumerable<Column> CurrentColumns {
            get;
        }

        /// <summary>
        /// Gets all the columns of the Grid
        /// </summary>
        IEnumerable<IColumnFactory> AllColumnFactory {
            get;
        }

        #endregion Properties
        #region Methods

        /// <summary>
        /// Initializes a new grid.
        /// A grid can be instantiated only once. If a new instanciation occurs, it will replace existing grid.
        /// </summary>
        /// <param name="options">options associated with the grid.</param>
        void Initialize(GridOptions options);

        /// <summary>
        /// Reload the grid, i.e. generate a javascript to recreate the grid.
        /// </summary>
        /// <returns>Javascript to recreate the grid.</returns>
        JavaScriptResult ReloadGrid();

        /// <summary>
        /// Changes the width of this column. It is only changing this width of this grid and update user preferences data for future new grid.
        /// </summary>
        /// <param name="columnName">name of the column</param>
        /// <param name="width">new width</param>
        void SetColumnWidth(string columnName, int width);

        /// <summary>
        /// Updates the list of columns
        /// </summary>
        /// <param name="visibleColumns">new visible columns</param>
        void RefreshColumn(List<string> visibleColumns);

        #endregion Methods
    }
}
